package com.sgb.contract.view.ui.details;

import android.text.TextUtils;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sgb.contract.R;
import com.sgb.contract.model.UpdateBean;

import java.util.List;

/**
 * 作者:张磊
 * 日期:2021/11/30 0030
 * 说明:修改的item
 */
public class UpdateAdapter extends BaseQuickAdapter<UpdateBean, BaseViewHolder> {


    public UpdateAdapter(List<UpdateBean> beans) {
        super(R.layout.contract_update_adapter, beans);
    }

    @Override
    protected void convert(BaseViewHolder helper, final UpdateBean item) {
        if (getData().size() == 0) {
            return;
        }
        helper
                .setText(R.id.tv_time, item.createTime + " " + item.userName)
                .setText(R.id.tv_userName, item.companyName)
                .setText(R.id.tv_content, item.operation)
                .setVisible(R.id.ll_btn, !TextUtils.isEmpty(item.originalContent));
        helper.getView(R.id.view1).setVisibility(helper.getLayoutPosition() == 0 ? View.INVISIBLE : View.VISIBLE);
        helper.getView(R.id.view2).setVisibility(helper.getLayoutPosition() == getData().size() - 1 ? View.INVISIBLE : View.VISIBLE);
        helper.addOnClickListener(R.id.ll_btn);
    }
}

